import { createPinia } from 'pinia';
import { createPersistedState } from 'pinia-plugin-persistedstate';

const pinia = createPinia();

const persistPlugin = createPersistedState({
  storage: {
    getItem(key) {
      return uni.getStorageSync(key);
    },
    setItem(key, value) {
      return uni.setStorageSync(key, value);
    },
  },
});

pinia.use(persistPlugin);

export default pinia;
